<?php


use Phinx\Migration\AbstractMigration;

class FillDefaultStatusData extends AbstractMigration
{

    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex13
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */

    /**
     * Migrate Up.
     * @throws Exception
     */
    public function up()
    {
        $rows = [
            [
                'name' => '未开始', //未开始
                'code' => 'not_started',
                'color' => '#ffb580',
                'icon' => 'el-icon-remove',
                'correspond' => 'not_started',
                'uuid' => Webpatser\Uuid\Uuid::generate()->string
            ],
            [
                'name' => '已就绪', //已就绪
                'code' => 'ready_to_start',
                'color' => '#ffb580',
                'icon' => 'el-icon-place',
                'correspond' => 'not_started',
                'uuid' => Webpatser\Uuid\Uuid::generate()->string
            ],
            [
                'name' => '已取消', //已取消
                'code' => 'closed',
                'color' => '#6310e8',
                'icon' => 'el-icon-video-pause',
                'correspond' => 'blocked',
                'uuid' => Webpatser\Uuid\Uuid::generate()->string
            ],
            [
                'name' => '进行中', //进行中
                'code' => 'inprogress',
                'color' => '#4e74f2',
                'icon' => 'el-icon-video-play',
                'correspond' => 'in_progress',
                'uuid' => Webpatser\Uuid\Uuid::generate()->string
            ],
            [
                'name' => '审核中', //审核中
                'code' => 'submitted',
                'color' => '#fabb1b',
                'icon' => 'el-icon-view',
                'correspond' => 'daily',
                'uuid' => Webpatser\Uuid\Uuid::generate()->string
            ],
            [
                'name' => '反馈', //反馈
                'code' => 'feedback',
                'color' => '#fabb1b',
                'icon' => 'el-icon-view',
                'correspond' => 'feedback',
                'uuid' => Webpatser\Uuid\Uuid::generate()->string
            ],
            [
                'name' => '已完成', //已完成
                'code' => 'final',
                'color' => '#ff5500',
                'icon' => 'el-icon-success',
                'correspond' => 'done',
                'uuid' => Webpatser\Uuid\Uuid::generate()->string
            ],
            [
                'name' => '待发布', //待发布
                'code' => 'ready_to_publish',
                'color' => '#ff8800',
                'icon' => 'el-icon-success',
                'correspond' => 'done',
                'uuid' => Webpatser\Uuid\Uuid::generate()->string
            ]
        ];

        $this->table('status')->insert($rows)->save();
    }

    /**
     * Migrate Down.
     */
    function down()
    {
        $this->execute('DELETE FROM status');
    }
}
